export default function (domVal) {
    return {
        mounted() {
            this.$bus.$on("setScroll", this.handleSetScroll);
            this.$refs[domVal].addEventListener("scroll", this.handleSetMainScroll);
        },
        beforeDestroy() {
            this.$bus.$emit('mainScroll', null)
            this.$bus.$off("setScroll", this.handleSetScroll);
            this.$refs[domVal].removeEventListener("scroll", this.handleSetMainScroll);
        },
        methods: {
            handleSetMainScroll() {
                this.$bus.$emit("mainScroll", this.$refs[domVal]);
            },
            handleSetScroll(top) {
                this.$refs[domVal].scrollTop = top;
            }
        }
    }
}